//twopts.txt - Like basic monst, but this character spends all its time 
// oscillating between its start point and a given nav point.
// Memory Cells:
//	 Cell 0 - The nav point the character marches out to.
//   Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this is killed, set to 1.
//   Cell 3 - Dialogue node when spoken to
//   Cell 4 - If nonzero, the character runs to its nav point immediately.
//     If 0, only goes occasionally.
//   Cell 5 - If they get to that point, just make them disappear

// WARNING dont send 2 characters to same nav point or they might get stuck. I 
// added code to remove an action point per move to prevent this

begincreaturescript;

variables;

short i,target;
short path_a_or_b = 0;
short last_walk;
short duration = 1;

body;

beginstate INIT_STATE;
	set_name(ME,"Bubbly Slime");
	last_walk = get_current_tick();
	break;

beginstate DEAD_STATE;
	// Set the appropriate stuff done flag for this character being dead
	if ((get_memory_cell(1) != 0) || (get_memory_cell(2) != 0))
		inc_flag(get_memory_cell(1),get_memory_cell(2),1);
break;

beginstate START_STATE; 
	duration = 1;
	if (difficulty() > 1)
		duration = 0;
	if (char_ok(1144)) {
		if ((tick_difference(last_walk,get_current_tick()) > duration) || (get_memory_cell(4) > 0)) {
			deduct_ap(1); // make sure to never infinite loop
				// if 2 characters heading to same spot
			if (approach_nav_point(ME,4,1)) {
				if (gf(11,13) == 0)
					sf(11,13,1);
				heal_char(1144,20 + get_ran(1,0,20) + difficulty() * 50);
				force_char_status(1144,0,4);
				if (difficulty() > 1)
					force_char_status(1144,4,4);
				run_text_on_char(1144,"Eats slime!",0);
				pc_heard_sound_delay(238,100);
				erase_char(ME);
				}
			}	
		}

	// if we're in combat and the above didn't give me anything to do, just
	// stop now. Otherwise, game will keep running script, and that eats up CPU time.
	if (am_i_doing_action() == FALSE)
		end_combat_turn();
break;

beginstate 3; // attacking
	if (target_ok() == FALSE)
		set_state(START_STATE);
	do_attack();
break;

beginstate TALKING_STATE;
	if (get_memory_cell(3) == 0) {
		print_str("Talking: You make a bit of small talk, but you don't learn anything interesting.");

		}
		else begin_talk_mode(get_memory_cell(3));
break;